//*************************类和对象****************************

import cjh.demo1.Computer;

public class Test {

    public static void main1(String[] args) {
        Student s1 = new Student();
        Student s2 = new Student();
        Student s3 = new Student();
        Student s4 = new Student();

        s1.name = "张三";
        s1.id = 110;
        s1.age = 13;
        s1.setStudent(s1.name,s1.id,s1.age);
        s1.print();

        s2.name = "李四";
        s2.age = 120;
        s2.age = 10;
        s2.setStudent(s2.name,s2.id,s2.age);
        s2.print();

        s3.name = "王五";
        s3.id = 119;
        s3.age = 29;
        s3.setStudent(s3.name,s3.id,s3.age);
        s3.print();

        s4.setStudent("赵六",10086,17);
        s4.print();

    }


    public static void main2(String[] args) {
        Cat c1 = new Cat();
        Cat c2 = new Cat();
        Cat c3 = new Cat();

        c1.name = "小小";
        c1.age = 2;
        c1.color = "黄色";
        c1.braks();
        c1.base(c1.name, c1.age, c1.color);
        c1.print();

        c2.name = "中中";
        c2.age = 5;
        c2.color = "黑色";
        c2.braks();
        c2.base(c2.name, c2.age, c2.color);
        c2.print();

        c3.braks();
        c3.base("大大", 8, "金色");
        c3.print();

    }


    public static void main3(String[] args) {
        Student s1 = new Student();
        Student s2 = new Student();

        //交换s1和s2这俩个对象的名字
        s1.setStudent("熊大",111,18);
        s2.setStudent("翠花",122,29);

        System.out.println("交换前");

        s1.print();
        s2.print();

        System.out.println("交换后");

        String tmp = s1.name;
        s1.name = s2.name;
        s2.name = tmp;

        s1.print();
        s2.print();

    }


    public static void main4(String[] args) {
        Student s1 = new Student();//调用不带参数的构造方法
        s1.print();
        //也可以调用重写toString
        //System.out.println(s1);

        Student s2 = new Student("小明", 888,19);//调用带参数的构造方法
        System.out.println(s2);//直接调用toString
    }


    public static void main5(String[] args) {
        //只要是在其他包中，类的方法&成员变量是public的，任何包都可以引用
        Computer cmp = new Computer();
        System.out.println(cmp);
    }



}
